package biblioteca;

import formularioPrincipal.JF_MenuPrincipal;
import javax.swing.JOptionPane;


public class JF_Login extends javax.swing.JFrame {

   public JF_Login() {

        initComponents();   
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTF_usuario = new javax.swing.JTextField();
        jTF_senha = new javax.swing.JPasswordField();
        jB_entrar = new javax.swing.JButton();
        jB_sair = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("SGB (Sistema Gerenciado da Biblioteca)");
        setBackground(new java.awt.Color(0, 0, 0));

        jPanel1.setBackground(new java.awt.Color(204, 255, 204));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 4, true), "Sessão de login", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Comic Sans MS", 1, 18), new java.awt.Color(0, 102, 0))); // NOI18N
        jPanel1.setForeground(new java.awt.Color(0, 102, 0));

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/biblioteca/mundo-na-palma-da-mão10 cópia.png"))); // NOI18N

        jLabel2.setFont(new java.awt.Font("Comic Sans MS", 1, 14));
        jLabel2.setForeground(new java.awt.Color(0, 102, 0));
        jLabel2.setText("Usuário:");

        jLabel3.setFont(new java.awt.Font("Comic Sans MS", 1, 14));
        jLabel3.setForeground(new java.awt.Color(0, 102, 0));
        jLabel3.setText("Senha:");

        jTF_usuario.setFont(new java.awt.Font("Tahoma", 1, 11));
        jTF_usuario.setForeground(new java.awt.Color(0, 102, 0));
        jTF_usuario.setToolTipText("Digite o nome do usuario");
        jTF_usuario.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 1, true));

        jTF_senha.setFont(new java.awt.Font("Tahoma", 1, 11));
        jTF_senha.setForeground(new java.awt.Color(0, 102, 0));
        jTF_senha.setToolTipText("Digite a senha do usuario");
        jTF_senha.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 1, true));
        jTF_senha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTF_senhaActionPerformed(evt);
            }
        });
        jTF_senha.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTF_senhaKeyTyped(evt);
            }
        });

        jB_entrar.setBackground(new java.awt.Color(204, 255, 204));
        jB_entrar.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
        jB_entrar.setForeground(new java.awt.Color(0, 102, 0));
        jB_entrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Png/Figura7.png"))); // NOI18N
        jB_entrar.setText("Entrar");
        jB_entrar.setToolTipText("Entrar");
        jB_entrar.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED, new java.awt.Color(0, 102, 0), java.awt.Color.lightGray), new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 1, true)));
        jB_entrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jB_entrarActionPerformed(evt);
            }
        });
        jB_entrar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jB_entrarKeyPressed(evt);
            }
        });

        jB_sair.setBackground(new java.awt.Color(204, 255, 204));
        jB_sair.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
        jB_sair.setForeground(new java.awt.Color(255, 0, 0));
        jB_sair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Png/Figura9.png"))); // NOI18N
        jB_sair.setText("Sair");
        jB_sair.setToolTipText("Sair");
        jB_sair.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED, new java.awt.Color(255, 0, 0), java.awt.Color.lightGray), new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 1, true)));
        jB_sair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jB_sairActionPerformed(evt);
            }
        });
        jB_sair.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jB_sairKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jTF_usuario, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE)
                    .addComponent(jTF_senha, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jB_sair, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(27, 27, 27)
                        .addComponent(jB_entrar, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel1))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(57, 57, 57)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTF_usuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(24, 24, 24)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTF_senha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jB_sair, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jB_entrar, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)))
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jB_entrar, jB_sair});

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-665)/2, (screenSize.height-413)/2, 665, 413);
    }// </editor-fold>//GEN-END:initComponents
    private void jTF_senhaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTF_senhaActionPerformed
        String a = jTF_usuario.getText();
        String b = jTF_senha.getText();

        if (("mano".equals(a)) && ("mano".equals(b))) {

            java.awt.EventQueue.invokeLater(new Runnable() {

                public void run() {
                    new JF_MenuPrincipal().setVisible(true);
                }
            });

            dispose();
        } else {
            JOptionPane.showMessageDialog(null, "Usuário ou senha incorreta !");
        }

    }//GEN-LAST:event_jTF_senhaActionPerformed

    private void jB_sairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jB_sairActionPerformed
        System.exit(WIDTH);        // TODO add your handling code here:
    }//GEN-LAST:event_jB_sairActionPerformed

    private void jB_entrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jB_entrarActionPerformed
        String a = jTF_usuario.getText();
        String b = jTF_senha.getText();

        if (("mano".equals(a)) && ("mano".equals(b))) {

            java.awt.EventQueue.invokeLater(new Runnable() {

                public void run() {
                    new JF_MenuPrincipal().setVisible(true);
                }
            });

            dispose();
        } else {
            JOptionPane.showMessageDialog(null, "Usuário ou senha incorreta !");
        }
}//GEN-LAST:event_jB_entrarActionPerformed

    private void jTF_senhaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTF_senhaKeyTyped
    }//GEN-LAST:event_jTF_senhaKeyTyped

    private void jB_entrarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jB_entrarKeyPressed
        String a = jTF_usuario.getText();
        String b = jTF_senha.getText();

        if (("mano".equals(a)) && ("mano".equals(b))) {

            java.awt.EventQueue.invokeLater(new Runnable() {

                public void run() {
                    new JF_MenuPrincipal().setVisible(true);
                }
            });

            dispose();
        } else {
            JOptionPane.showMessageDialog(null, "Usuário ou senha incorreta !");
        }
    }//GEN-LAST:event_jB_entrarKeyPressed

    private void jB_sairKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jB_sairKeyPressed
    System.exit(0);
    }//GEN-LAST:event_jB_sairKeyPressed

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new JF_Login().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jB_entrar;
    private javax.swing.JButton jB_sair;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jTF_senha;
    private javax.swing.JTextField jTF_usuario;
    // End of variables declaration//GEN-END:variables

    
}
